home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxxfont.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  6.5 KB  |  175 lines

  1. /* Copyright (C) 1992, 1993, 1994, 1996 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxxfont.h,v 1.2 2000/09/19 19:00:40 lpd Exp $ */
  20. /* External font interface for Ghostscript library */
  21.  
  22. #ifndef gxxfont_INCLUDED
  23. #  define gxxfont_INCLUDED
  24.  
  25. #include "gsccode.h"
  26. #include "gsmatrix.h"
  27. #include "gsuid.h"
  28. #include "gsxfont.h"
  29.  
  30. /*
  31.  *                    Design issues for external fonts
  32.  *
  33.  * 1. Where do xfonts come from: a device or a font service?
  34.  *
  35.  * 2. Is a given xfont associated with a particular device, or with a
  36.  *    class of devices, which may have different output media?
  37.  *    (Specifically, Windows displays vs. printers.)
  38.  *
  39.  * 3. Is an xfont a handle that must be interpreted by its originator,
  40.  *    or an object with its own set of operations?
  41.  *
  42.  * 4. Are xfonts always transformation-specific, or is there such a thing
  43.  *    as a scalable xfont?
  44.  *
  45.  * 5. What is the meaning of the transformation matrix supplied when
  46.  *    asking for an xfont?
  47.  *
  48.  *                      Answers (for the current design)
  49.  *
  50.  * 1. Devices supply xfonts.  Internal devices (image, null, clipping,
  51.  *    command list, tracing) forward font requests to a real underlying
  52.  *    device.  File format devices should do the same, but right now
  53.  *    they don't.
  54.  *
  55.  * 2. An xfont is not associated with anything: it just provides bitmaps.
  56.  *    Since xfonts are only used at small sizes and low resolutions,
  57.  *    tuning differences for different output media aren't likely to be
  58.  *    an issue.
  59.  *
  60.  * 3. Xfonts are objects.  They are allocated by their originator, and
  61.  *    (currently) only freed by `restore'.
  62.  *
  63.  * 4. Xfonts are always transformation-specific.  This may lead to some
  64.  *    clutter, but it's very unlikely that a document will have enough
  65.  *    different transformed versions of a single font for this to be a
  66.  *    problem in practice.
  67.  *
  68.  * 5. The transformation matrix is the CTM within the BuildChar or BuildGlyph
  69.  *    procedure.  This maps a 1000x1000 square to the intended character size
  70.  *    (assuming the base font uses the usual 1000-unit scaling).
  71.  */
  72.  
  73. /* The definitions for xfonts are very similar to those for devices. */
  74.  
  75. /* Structure for generic xfonts. */
  76. typedef struct gx_xfont_common_s {
  77.     const gx_xfont_procs *procs;
  78. } gx_xfont_common;
  79.  
  80. /* A generic xfont. */
  81. struct gx_xfont_s {
  82.     gx_xfont_common common;
  83. };
  84.  
  85. /* Definition of xfont procedures. */
  86.  
  87. struct gx_xfont_procs_s {
  88.  
  89.     /* Look up a font name, UniqueID, and matrix, and return */
  90.     /* an xfont. */
  91.  
  92.     /* NOTE: even though this is defined as an xfont_proc, */
  93.     /* it is actually a `factory' procedure, the only one that */
  94.     /* does not take an xfont * as its first argument. */
  95.  
  96. #define xfont_proc_lookup_font(proc)\
  97.   gx_xfont *proc(P7(gx_device *dev, const byte *fname, uint len,\
  98.     int encoding_index, const gs_uid *puid, const gs_matrix *pmat,\
  99.     gs_memory_t *mem))
  100.     xfont_proc_lookup_font((*lookup_font));
  101.  
  102.     /*
  103.      * Convert a character name to an xglyph code.  encoding_index is
  104.      * actually a gs_encoding_index_t.  Either chr or glyph may be absent
  105.      * (gs_no_char/glyph), but not both.
  106.      */
  107.     /* OBSOLETE as of release 3.43, but still supported. */
  108.  
  109. #define xfont_proc_char_xglyph(proc)\
  110.   gx_xglyph proc(P5(gx_xfont *xf, gs_char chr, int encoding_index,\
  111.     gs_glyph glyph, gs_proc_glyph_name((*glyph_name))))
  112.     xfont_proc_char_xglyph((*char_xglyph));
  113.  
  114.     /* Get the metrics for a character. */
  115.     /* Note: pwidth changed in release 2.9.7. */
  116.  
  117. #define xfont_proc_char_metrics(proc)\
  118.   int proc(P5(gx_xfont *xf, gx_xglyph xg, int wmode,\
  119.     gs_point *pwidth, gs_int_rect *pbbox))
  120.     xfont_proc_char_metrics((*char_metrics));
  121.  
  122.     /* Render a character. */
  123.     /* (x,y) corresponds to the character origin. */
  124.     /* The target may be any Ghostscript device. */
  125.  
  126. #define xfont_proc_render_char(proc)\
  127.   int proc(P7(gx_xfont *xf, gx_xglyph xg, gx_device *target,\
  128.     int x, int y, gx_color_index color, int required))
  129.     xfont_proc_render_char((*render_char));
  130.  
  131.     /* Release any external resources associated with an xfont. */
  132.     /* If mprocs is not NULL, also free any storage */
  133.     /* allocated by lookup_font (including the xfont itself). */
  134.  
  135. #define xfont_proc_release(proc)\
  136.   int proc(P2(gx_xfont *xf, gs_memory_t *mem))
  137.     xfont_proc_release((*release));
  138.  
  139.     /* Convert a character name to an xglyph code. */
  140.     /* This is the same as char_xglyph, except that */
  141.     /* it takes a vector of callback procedures. */
  142.     /* (New in release 3.43.) */
  143.  
  144. #define xfont_proc_char_xglyph2(proc)\
  145.   gx_xglyph proc(P5(gx_xfont *xf, gs_char chr, int encoding_index,\
  146.     gs_glyph glyph, const gx_xfont_callbacks *callbacks))
  147.     xfont_proc_char_xglyph2((*char_xglyph2));
  148.  
  149. };
  150.  
  151. /*
  152.  * Since xfonts are garbage-collectable, they need structure descriptors.
  153.  * Fortunately, the common part of an xfont contains no pointers to
  154.  * GC-managed space, so simple xfonts can use gs_private_st_simple.
  155.  * The following macro will serve for an xfont with only one pointer,
  156.  * to its device:
  157.  */
  158. #define gs__st_dev_ptrs1(scope_st, stname, stype, sname, penum, preloc, de)\
  159.   private ENUM_PTRS_WITH(penum, stype *xfptr) return 0;\
  160.     case 0: ENUM_RETURN(gx_device_enum_ptr((gx_device *)(xfptr->de)));\
  161.   ENUM_PTRS_END\
  162.   private RELOC_PTRS_WITH(preloc, stype *xfptr) ;\
  163.     xfptr->de = (void *)gx_device_reloc_ptr((gx_device *)(xfptr->de), gcst);\
  164.   RELOC_PTRS_END\
  165.   gs__st_composite_only(scope_st, stname, stype, sname, penum, preloc)
  166. /*
  167.  * We probably don't ever want xfont descriptors to be public....
  168. #define gs_public_st_dev_ptrs1(stname, stype, sname, penum, preloc, de)\
  169.   gs__st_dev_ptrs1(public_st, stname, stype, sname, penum, preloc, de)
  170.  */
  171. #define gs_private_st_dev_ptrs1(stname, stype, sname, penum, preloc, de)\
  172.   gs__st_dev_ptrs1(private_st, stname, stype, sname, penum, preloc, de)
  173.  
  174. #endif /* gxxfont_INCLUDED */
  175.